package ar.Location.UI;

import java.util.ArrayList;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import ar.Location.Weather_2.ForecastDay;
import ar.activity.LocalWeatherForecastActivity;

public class WeatherAdapter extends BaseAdapter {

	public Context mContext = null;
	public ArrayList<ForecastDay> listForecastDays = null;
	
	public WeatherAdapter(Context context) {
		mContext = context;
		if(LocalWeatherForecastActivity.localWeather != null) {
			listForecastDays = LocalWeatherForecastActivity.localWeather.listForecastDays;
		}
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		if(listForecastDays != null) {
			return listForecastDays.size();
		}
		return 0;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		WeatherItemView weatherItemView = (WeatherItemView) convertView;
		
		if(weatherItemView == null) {
			weatherItemView = new WeatherItemView(mContext);
		}
		
		if(listForecastDays != null) {
			if(position < listForecastDays.size()) {
				weatherItemView.bindData(listForecastDays.get(position));
			}
		}
		
		return weatherItemView;
	}

}
